
<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>修改用户信息</title>
    <link rel="shortcut icon" href="favicon.ico"> 
    <link href="${WEB_PATH}/resources/css/bootstrap.min.css?v=3.3.5" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/font-awesome.min.css?v=4.4.0" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/plugins/chosen/chosen.css" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/style.min.css?v=5.0.0" rel="stylesheet"><base target="_blank">
	<link href="${WEB_PATH}/resources/css/plugins/sweetalert/sweetalert.css" rel="stylesheet">
	<link href="${WEB_PATH}/resources/css/plugins/treeview/bootstrap-treeview.css" rel="stylesheet">
    <link href="${WEB_PATH}/resources/css/plugins/jsTree/style.min.css" rel="stylesheet">
	<link href="${WEB_PATH}/resources/css/plugins/awesome-bootstrap-checkbox/awesome-bootstrap-checkbox.css" rel="stylesheet">
	
</head>

<body>
	<div class="col-sm-12">
		<form class="m-t" id="addUserInfo">
            <div class="form-group">
                <label>用户类型：</label>
                <input id="ID" name="ID" type="hidden" value="${user.ID}" >
                <input id="status" name="status" type="hidden" value="${user.status}" >
                <select data-placeholder="选择角色类型" id="userType" name="userType" class="chosen-select form-control">
				   <option value="st" <#if user.userType == "st">selected = "selected"</#if>>省厅用户</option> 
				   <option value="dz" <#if user.userType == "dz">selected = "selected"</#if>>地州用户</option> 
				   <option value="jcjg" <#if user.userType == "jcjg">selected = "selected"</#if>>检测机构用户</option> 
				</select> 
        	</div> 
            <div class="form-group"  id="organization_id">
                <label>所属组织部门：</label>
                <select data-placeholder="选择所属组织部门" id="organizationId" name="organization.ID"  class="chosen-select form-control" >
                   <option  value="" hassubinfo="true" ></option>
                   <@portsCount type="dzList">
                       <#list dzList as dz >
					       <option value="${dz.ID}" <#if user.organization.ID == dz.ID>selected = "selected"</#if>> ${dz.name}</option>
					   </#list>
				   </@portsCount>
				</select>
            </div>
            <div class="form-group"  id="tsorganizationInfo">
                <label>所属检测机构：</label>
                <select data-placeholder="选择所属检验机构" id="tsorganizationInfoId" name="tsorganizationInfo.ID"  class="chosen-select form-control" >
                   <option  value="" hassubinfo="true" ></option>
                   <@tsorganizationInfos>
                       <#list tsorganizationInfos as tsorganizationInfo >
					       <option value="${tsorganizationInfo.ID}"  <#if user.tsorganizationInfo.ID == tsorganizationInfo.ID>selected = "selected"</#if>>${tsorganizationInfo.JYJGMC}</option>
					   </#list>
				   </@tsorganizationInfos>
				</select>
            </div>
            <div class="form-group">
                <label>账号：</label>
                <input id="account"name="account" maxlength="16" onkeyup="value=value.replace(/[^\w\.\/]/ig,'')" type="text"  class="form-control"    placeholder="请输入账号" value="${user.account}">
            </div>
            <div class="form-group">
                <label>姓名：</label>
                <input id="name" name="name" class="form-control"   placeholder="请输入姓名" value="${user.name}">
            </div> 
            <div class="form-group">
                <label>手机号：</label>
                <input id="phone" name="phone" type="text" class="form-control" onkeyup="this.value=this.value.replace(/\D/g,'')" maxlength="11"   placeholder="请输入手机号" value="${user.phone}">
            </div> 
        </form> 
	</div>
    <script src="${WEB_PATH}/resources/js/jquery.min.js?v=2.1.4"></script>
    <script src="${WEB_PATH}/resources/js/ajax.extend.js"></script>
    <script src="${WEB_PATH}/resources/js/bootstrap.min.js?v=3.3.5"></script>
	<script src="${WEB_PATH}/resources/js/plugins/datapicker/bootstrap-datepicker.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/wizard/jquery.bootstrap.wizard.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/validate/jquery.validate.min.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/validate/messages_zh.min.js"></script>
    <script src="${WEB_PATH}/resources/js/plugins/validate/jquery.validate.method.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/layer/layer.js"></script> 
	<script src="${WEB_PATH}/resources/js/plugins/jsTree/jstree.min.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/sweetalert/sweetalert.min.js"></script>
	<script src="${WEB_PATH}/resources/js/plugins/chosen/chosen.jquery.js"></script>
	<script>
	$(function(){
		var userType = "${user.userType}";
		if(userType == "dz"){
	  		$("#organization_id").show();
	  		$("#tsorganizationInfo").hide();
	  	}else if(userType == "jcjg"){
	  		$("#tsorganizationInfo").show();
	  		$("#organization_id").hide();
	  	}else if(userType == "st"){
	  		$("#tsorganizationInfo").hide();
	  		$("#organization_id").hide();
	  	}
    	$("#roleIds").chosen({width:'100%'}); 
    	$("#tsorganizationInfoId").chosen({width:'100%'}); 
    	$("#organizationId").chosen({width:'100%'}); 
    	$("#userType").change(function(){
    		var userType = $("#userType").val();
		  	if(userType == "dz"){
		  		$("#organizationName").val("");
                $("#organizationId").val("");
                $("#organization_code").val("");
		  		$("#organization_id").show();
		  		$("#tsorganizationInfo").hide();
		  	}else if(userType == "jcjg"){
		  		$("#tsorganizationInfo").show();
		  		$("#organization_id").hide();
		  	}else if(userType == "st"){
		  		$("#tsorganizationInfo").hide();
		  		$("#organization_id").hide();
		  	}
		});
		 
    });
	var e = "<i class='fa fa-times-circle'></i> ";
	$("#addUserInfo").validate({
	 	rules: {
        	account: {
                required: !0,
                rangelength: [5, 16],
                remote:{
                	  type:"POST",
                      url:"${WEB_PATH }/system/user/checkName.do?old=${user.account}",
                }
            },
            name: {
            	required: !0,
            },
            password: {
                required: !0,
                rangelength: [5, 16],
                isPasword:true,
            },
            phone: {
                required: !0,
                isMobile: !0,
                rangelength: [11,11],
            }
        },
        messages: {
            account: {
                required: e + "请输入账号名称。",
                remote: e + "账号名称重复。"
            },
            name: {
            	required: e + "请输入姓名。",
            },
            password: {
                required: e + "请输入密码。",
                rangelength: e + "密码由字母和数字混合组成长度必须6到16个字符之间	。",
            },
            phone: {
                required: e + "请输入手机号。",
                rangelength:e + "请输入正确的手机号。",
                isMobile:e+"请输入正确的手机号。"
            }
        },
        errorPlacement: function(error, element) {
        	element.before(error);
         }
   });
 	 //修改用户信息#commentForm
 	function updateInfo(){
 		var userType = $("#userType").val();
		if(userType == "dz"){
	  		if($("#organizationName").val()==""){
	  			layer.msg('请选择所属组织部门！', {icon: 5}); 
		   		return false;
	  		}
	  	}else if(userType == "jcjg"){
	  		if($("#tsorganizationInfoId").val()==""){
	  			layer.msg('请选择所属检测机构！', {icon: 5}); 
		   		return false;
	  		}
	  	} 
 		if($("#addUserInfo").valid()){
			$.yilinAjax({
		   	  	type:'POST',
		   	  	loadmsg:'努力提交中......',
		   	  	url:'${WEB_PATH }/system/user/update.do',
		   	  	data:$('#addUserInfo').serialize(),
        		errorcallback:null,
        		btn:null,
        		successcallback:success
	   	    });
    	 }
 	}
 	
 	function success(result){  
 		if(result.success == true){
			 layer.alert('<font color="#1ab394">'+result.msg+'</font>', {
			  	skin: 'layui-layer-molv',
			  	icon: 1,
			  	closeBtn: 0
			},function(){
				parent.$("#exampleTableEvents").bootstrapTable('refresh');
			   	var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
			   	parent.$('#addUser').attr("disabled",false);
				parent.layer.close(index); 
				
			});
		}else{ 
	    	layer.msg(result.msg, {icon: 5}); 
		} 
    }
  </script>
</body>
</html>